# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=autogen
pkgver=5.18.16
pkgrel=1
pkgdesc="A tool designed to simplify the creation and maintenance of programs that contain large amounts of repetitious text"
arch=('i686' 'x86_64')
url="https://autogen.sourceforge.io/"
groups=('base-devel')
license=('GPL3')
makedepends=('gcc' 'gmp-devel' 'libcrypt-devel' 'libffi-devel' 'libgc-devel' 'libguile-devel' 'libxml2-devel')
depends=('gcc-libs' 'gmp' 'libcrypt' 'libffi' 'libgc' 'libguile' 'libxml2')
install=autogen.install
source=("https://ftp.gnu.org/gnu/${pkgname}/rel${pkgver}/${pkgname}-${pkgver}.tar.xz"{,.sig}
        autogen-5.18.1-msys2.patch)
sha256sums=('f8a13466b48faa3ba99fe17a069e71c9ab006d9b1cfabe699f8c60a47d5bb49a'
            'SKIP'
            'ff3df8d191a6269a2f64b6ec19d24bb5d169d316104f97f14a094633aaa77386')
validpgpkeys=('3EEE51D1355B8EC40D9F3122495143D05D0712D1')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i ${srcdir}/autogen-5.18.1-msys2.patch
  autoreconf -fiv
}

build() {
  LDFLAGS+=' -Wl,--export-all-symbols'
  CFLAGS+=" -Wno-implicit-fallthrough -Wno-format-overflow -Wno-format-truncation"
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure \
    --build=${CHOST} \
    --host=${CHOST} \
    --prefix=/usr \
    --disable-dependency-tracking
  make all
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  #make -k check
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
  if [ -d ${pkgdir}/usr/share/pkgconfig ]; then
    mv ${pkgdir}/usr/share/pkgconfig ${pkgdir}/usr/lib/
  fi
}
